import { FormControlLabel } from '@mui/material';
import { Label } from '.';
import { Checkbox as AntdCheckbox } from 'antd';

interface IProps {
  label?: string;
  disabled: boolean;
  checked: boolean;
  onChange: (value: boolean) => void;
}
export default function Checkbox({
  label,
  disabled,
  checked,
  onChange,
}: IProps) {
  const cb = (
    <AntdCheckbox
      style={{ marginRight: 5, marginLeft: 10 }}
      disabled={disabled}
      checked={checked}
      onChange={(e) => onChange(e.target.checked)}
    />
  );
  if (label === undefined) {
    return cb;
  }
  return (
    <FormControlLabel
      control={cb}
      disabled={disabled}
      label={<Label label={label} />}
    />
  );
}
